import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { User } from './user.entity';
import { Repository } from 'typeorm';
@Injectable()
export class UserService {
  constructor(
    @InjectRepository(User) private usersRepository: Repository<User>,
  ) {}
  async findAll() {
    return this.usersRepository.find();
  }
  findOne(id) {
    return this.usersRepository.findOneBy({ id });
  }
  async create(data) {
    const dataes = await this.usersRepository.create(data);
    await this.usersRepository.save(dataes);
    return dataes;
  }
  async update(id, data) {
    const dataes = await this.usersRepository.update(id, data);
    return dataes;
  }
}
